

package commandz.var;


/**
 *  A String type specialized implementation of the Variable interface.
 *
 *  This class is applicable when a Variable for string literals is needed.
 */
public class VariableString implements Variable
{
    private final String VARIABLE_NAME = "literal";

    protected String value;


    /**
     *  Initializes a new instance of this VariableString
     *  with a default empty string.
     */
    public VariableString()
    {
        this.value = "";
    }


    /**
     *  Initializes a new instance of this VariableString
     *  with the given value.
     */
    public VariableString(final String value)
    {
        this.value = value;
    }


    /**
     *  Assigns the value of this VariableString to the given one.
     *
     *  @param value A String value to use.
     */
    public void setValue(final String value)
    {
        this.value = value;
    }


    /**
     *  Returns the value of this VariableString.
     *
     *  @return A String value.
     */
    public String getValue()
    {
        return this.value;
    }


    /**
     *  Returns the name of the type of this Variable.
     *
     *  @return A String which describes the type of this Variable.
     */
    public String getTypeName()
    {
        return this.VARIABLE_NAME;
    }


    /**
     *  Parses the given string into the value of this VariableString.
     *
     *  @param str A String.
     *
     *  @return true.
     */
    public boolean parse(final String str)
    {
        this.value = str;  // ;-)
        return true;
    }


    /**
     *  Formats the value of this Variable into a readable String.
     *
     *  @return The value of this Variable.
     */
    public String format()
    {
        return value;
    }
}
